package com.yicoollxing.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yicoollxing.common.ResponseCode;
import com.yicoollxing.common.ServerResponse;
import com.yicoollxing.dao.mapper.EvaluateMapper;
import com.yicoollxing.pojo.Evaluate;
import com.yicoollxing.service.IEvaluateService;

@Service("iEvaluateService")
public class EvaluateServiceImpl implements IEvaluateService {

	@Autowired
	private EvaluateMapper evaluateMapper;

	public ServerResponse list(Integer pageNum, Integer pageSize, Integer mid) {
		if (mid == null) {
			return ServerResponse.createByErrorCodeMessage(
					ResponseCode.ILLEGAL_ARGUMENT.getCode(),
					ResponseCode.ILLEGAL_ARGUMENT.getDesc());
		}
		List<Evaluate> evaluates = evaluateMapper.selectByMid(mid);
		PageHelper pageHelper = new PageHelper();
		pageHelper.startPage(pageNum, pageSize);
		PageInfo pageInfo = new PageInfo(evaluates);
		return ServerResponse.createBySuccess(pageInfo);
	}
}
